home *** CD-ROM | disk | FTP | other *** search
- /*
- Free File Selector V0.03
- Copyright(C)1993 Okome
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <direct.h>
- #include <dos.h>
- #include <EGB.H>
- #include <MOS.H>
- #include <FMCfrb.h>
- #include <normlib.h>
- #include <okome.h>
-
- /* サイズ */
- #define FX3 330
- #define FY3 200
- #define FX2 (Fx1+FX3)
- #define FY2 (Fy1+FY3)
- #define kx (Fx1+16)
- #define ky (FY2-24)
- #define xe (FX3-20)
-
- extern char work[];
-
- void cccp( int x1, int y1, int x2, int y2, int x3, int y3, int sx, int sy )
- {
- int y, ya, yb, yz;
- char w0[1024], w1[1024];
- if (y1<y2)
- {
- ya=sy;
- yb=-1;
- yz=-1;
- } else {
- ya=0;
- yb=sy+1;
- yz=1;
- }
- for (y=ya; y!=yb; y+=yz)
- {
- egbget( x3, y3+y, x3+sx, y3+y, w0 );
- egbget( x1, y1+y, x1+sx, y1+y, w1 );
- egbput( x1, y1+y, x1+sx, y1+y, w0 );
- egbget( x2, y2+y, x2+sx, y2+y, w0 );
- egbput( x2, y2+y, x2+sx, y2+y, w1 );
- egbput( x3, y3+y, x3+sx, y3+y, w0 );
- }
- }
-
- static int Fx1=140, Fy1=70;
- static unsigned int edr;
- static struct _diskfree_t fre;
-
- void wido( int *x, int *y, int sx, int sy )
- {
- int mb, mx, my, mx2, my2;
- MOS_rdpos( &mb, &mx, &my );
- if (mx>=*x && my>=*y && mx<=*x+sx && my <= *y+sy )
- {
- mbout( &mb, &mx2, &my2 );
- MOS_disp(0);
- cccp( *x,*y, *x-mx+mx2,*y-my+my2, 640,0, sx,sy );
- MOS_disp(1);
- *x = *x-mx+mx2;
- *y = *y-my+my2;
- }
- }
-
- static void fvr( int l, int c, struct _find_t fls[] )
- {
- int i, x, y;
- i = l*3;
- boxbf( Fx1+6, Fy1+24, Fx1+xe, FY2-26, 15, 8 );
- for ( y=0; (y+1) * 18 <= 152; y++ )
- {
- for ( x=0; (x+1) * 100 < xe; x++ )
- {
- if ( i < c )
- {
- if ( fls[i].attrib & _A_SUBDIR )
- {
- EGB_color( work, 0, 14 );
- } else {
- EGB_color( work, 0, 15 );
- }
- print( Fx1+8+x*100, Fy1+40+y*18, fls[i++].name );
- } else {
- fls[i++].name[0] = 0;
- }
- }
- }
- }
-
- static int fdir( struct _find_t fls[] ) /* ファイル格納 */
- {
- int c=0;
- char drn[128];
- struct _find_t fl;
-
- /* ディレクトリ確定 */
- _getcwd( drn, 124 );
- if ( drn[3]==0 )
- {
- drn[2] = 0;
- }
- strcat( drn, "\\*.*" );
- /* ファイル情報 */
- if ( _dos_findfirst( drn, _A_NORMAL | _A_SUBDIR, &fl ) == 0 )
- {
- fls[c++] = fl;
- while ( _dos_findnext(&fl) == 0 )
- {
- fls[c++] = fl;
- }
- fvr( 0, c, fls ); /* ファイル名表示 */
- }
- return (c);
- }
-
- /* HEat file_select("mac",msg,drv,dir,wild,sort) */
- /*
- file_select("FILE","編集ファイル",-1, "", "*.*",-1)
- if ( FILE = "" )
- { FILE = "dummy.mml"
- }
- */
- int fsel( char *fna, char *msg, char dr )
- {
- int i, x, y, mb, mx, my, c, d, p, rp=1, t=1, l=0;
- unsigned int drv;
- struct _find_t fls[256];
- char w[1024];
-
- p = EGB_getWritePage( 0, 0 );
- EGB_writePage( work, 0 );
- MOS_disp(0);
- for (y=Fy1; y<=FY2; y++)
- {
- egbget( Fx1, y, FX2, y, w );
- egbput( 640,y-Fy1, 640+FX3,y-Fy1, w );
- }
-
- /* ドライブ設定 */
- if (isalpha(dr))
- dr = tolower(dr) - 'a';
- dr++;
- if (dr == 0)
- {
- _dos_getdrive( &edr );
- dr = edr;
- }
- _dos_setdrive( dr, &edr );
- drv = dr;
-
- /* ドライブ情報 */
- _dos_getdiskfree( drv, &fre );
-
- /* 画面原型 */
- boxbf( Fx1,Fy1, FX2,FY2, 8, 6 );
- boxf( Fx1+1, Fy1+1, Fx1+16+strlen(msg)*8, Fy1+18, 8 );
- boxbf( FX2-16, Fy1+32, FX2-2, FY2-26, 15, 7 );
- boxbf( kx, ky, kx+104, ky+20, 15, 8 );
- boxb( FX2-100, Fy1+18, FX2-20, Fy1, 15 );
- boxb( FX2-80, Fy1+18, FX2-40, Fy1, 15 );
- EGB_color( work, 0, 15 );
- EGB_fontStyle( work, 0 );
- print( Fx1+7,Fy1+17, msg );
- print( Fx1+18, FY2-6, fna );
- w[0]=drv+'A'-1;
- w[1]=0;
- symbol(FX2-80,Fy1+17,w,16,15);
-
- c = fdir(fls);
- /* マウス処理 */
- MOS_disp(1);
- do
- {
- do
- {
- MOS_rdpos( &mb, &x, &y );
- switch(keyin(Fx1+18, FY2-21, fna, 12, 15, 8, t ))
- {
- case 0:
- mb=3;
- rp=0;
- break;
- case 2:
- mb=3;
- break;
- default:
- break;
- }
- t = 0;
- } while( mb == 0 );
- d = 0;
- x -= Fx1;
- y -= Fy1;
- if (x>=8 && y>=23 && x<=xe+8 && y<=FY3-26)
- {
- d++;
- i = (x-8)/100+((y-23)/18+l)*3;
- if (fls[i].attrib & _A_SUBDIR)
- {
- _chdir(fls[i].name);
- MOS_disp(0);
- c = fdir(fls);
- l = 0;
- MOS_disp(1);
- mbout( &mb, &x, &y );
- } else {
- if ( strcmp( fna, fls[i].name )!=0 )
- {
- strcpy( fna, fls[i].name );
- t = 1;
- }
- }
- }
- if ( x > FX3-100 && y < 18 && x<FX3-80 && y>0)
- {
- d++;
- MOS_disp(0);
- boxf(FX2-80,Fy1+1,FX2-70,Fy1+17,0);
- if (drv>1)
- {
- drv--;
- } else {
- drv = edr;
- }
- w[0]=drv+'A'-1;
- w[1]=0;
- symbol(FX2-80,Fy1+17,w,16,15);
- MOS_disp(1);
- mbout( &mb, &mx, &my );
- }
- if ( x > FX3-40 && y < 18 && x<FX3-20 && y>0)
- {
- d++;
- MOS_disp(0);
- boxf(FX2-80,Fy1+1,FX2-70,Fy1+17,0);
- if (drv<edr) drv++;
- w[0]=drv+'A'-1;
- w[1]=0;
- symbol(FX2-80,Fy1+17,w,16,15);
- MOS_disp(1);
- mbout( &mb, &mx, &my );
- }
- if ( x > FX3-80 && y < 18 && x<FX3-40 && y>0)
- {
- d++;
- MOS_disp(0);
- _dos_setdrive( drv, &edr );
- _dos_getdiskfree( drv, &fre );
- c = fdir(fls);
- l= 0;
- MOS_disp(1);
- mbout( &mb, &mx, &my );
- }
- if ( 16 < x && FY3-24 < y && 16+104 > x && FY3-4 > y )
- {
- d++;
- rp = 0;
- mb = 3;
- }
- if ( x>=FX3-16 && x<=FX3-2 && y>=32 && y<=FY3-26 && l<c/3)
- {
- d++;
- fvr( ++l, c, fls );
- }
- if ( d == 0)
- {
- wido( &Fx1, &Fy1, FX3, FY3 );
- }
- } while( mb != 3 );
- MOS_disp(0);
- for (y=Fy1; y<=FY2; y++)
- {
- egbget( 640,y-Fy1, 640+FX3,y-Fy1, w );
- egbput( Fx1, y, FX2, y, w );
- }
- MOS_disp(1);
- EGB_writePage( work, p );
- return (rp);
- }
-